package pack0824;

import java.io.*;
import java.util.Scanner;

public class DemoA {
    public static void a(){
        try{
            Scanner in = new Scanner(System.in);
            File file = new File("D://a//a.txt");
            OutputStream out = new FileOutputStream(file,true);//append追加，
            while (true){
                System.out.println("请写入你想写入的字符：");
                String s = in.next();
                if(s.equals("exit")){
                    break;
                }
                byte[] bytes = (s+"\n").getBytes();
                out.write(bytes);
            }
            out.close();//关闭io流
        }catch (FileNotFoundException e){
            System.out.println(e.getMessage());
        }catch (IOException e){
            System.out.println(e.getMessage());
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }

    public static void main(String[] args) {
        a();
    }
}
